﻿Public Class RperfilUsuario

    Public Shared Function SeleccionarTodo(ByVal descEmpresa As String, ByVal DisplaySelect As Boolean) As List(Of EperfilUsuario)
        Dim perfils As List(Of EperfilUsuario) = Nothing

        Dim options As New TransactionOptions
        options.IsolationLevel = Transactions.IsolationLevel.ReadCommitted
        options.Timeout = New TimeSpan(0, 2, 0)

        Using scope As New TransactionScope(TransactionScopeOption.Required, options)
            Try
                perfils = DperfilUsuario.SeleccionarTodo(descEmpresa)
                If perfils Is Nothing Then perfils = New List(Of EperfilUsuario)
                If DisplaySelect Then perfils.Insert(0, New EperfilUsuario("00", "-- SELECCIONAR --"))
                scope.Complete()
            Catch ex As Exception
                Throw
            End Try
        End Using

        Return perfils
    End Function
    Public Shared Function SeleccionarPerfil(ByVal descEmpresa As String, ByVal idPerfil As Int32) As EperfilUsuario
        Dim perfil As EperfilUsuario = Nothing

        Dim options As New TransactionOptions
        options.IsolationLevel = Transactions.IsolationLevel.ReadCommitted
        options.Timeout = New TimeSpan(0, 2, 0)

        Using scope As New TransactionScope(TransactionScopeOption.Required, options)
            Try
                perfil = DperfilUsuario.SeleccionarPerfil(descEmpresa, idPerfil)
                If perfil Is Nothing Then perfil = New EperfilUsuario
                scope.Complete()
            Catch ex As Exception
                Throw
            End Try
        End Using

        Return perfil
    End Function
    Public Shared Function Añadir(ByVal descEmpresa As String, ByVal pPerfiles As EperfilUsuario) As Boolean
        Dim resultado As Boolean = False

        Dim options As New TransactionOptions
        options.IsolationLevel = Transactions.IsolationLevel.ReadCommitted
        options.Timeout = New TimeSpan(0, 2, 0)

        Using scope As New TransactionScope(TransactionScopeOption.Required, options)
            Try
                resultado = DperfilUsuario.Añadir(descEmpresa, pPerfiles)
                scope.Complete()
            Catch ex As Exception
                Throw
            End Try
        End Using

        Return resultado
    End Function
    Public Shared Function Editar(ByVal descEmpresa As String, ByVal pPerfiles As EperfilUsuario) As Boolean
        Dim resultado As Boolean = False

        Dim options As New TransactionOptions
        options.IsolationLevel = Transactions.IsolationLevel.ReadCommitted
        options.Timeout = New TimeSpan(0, 2, 0)

        Using scope As New TransactionScope(TransactionScopeOption.Required, options)
            Try
                resultado = DperfilUsuario.Editar(descEmpresa, pPerfiles)
                scope.Complete()
            Catch ex As Exception
                Throw
            End Try
        End Using

        Return resultado
    End Function
    Public Shared Function Eliminar(ByVal descEmpresa As String, ByVal pPerfiles As EperfilUsuario) As Boolean
        Dim resultado As Boolean = False

        Dim options As New TransactionOptions
        options.IsolationLevel = Transactions.IsolationLevel.ReadCommitted
        options.Timeout = New TimeSpan(0, 2, 0)

        Using scope As New TransactionScope(TransactionScopeOption.Required, options)
            Try
                resultado = DperfilUsuario.Eliminar(descEmpresa, pPerfiles)
                scope.Complete()
            Catch ex As Exception
                Throw
            End Try
        End Using

        Return resultado
    End Function

End Class
